import request from '@/utils/request'

// 根据购物车选中商品生成订单
export const createOrder = () => {
  return request('/member/order/pre', 'get')
}
// 添加收货地址
export const addAddress = (form) => {
  return request('/member/address', 'post', form)
}
// 修改收货地址
export const editAddress = (form) => {
  return request(`/member/address/${form.id}`, 'put', form)
}
// 提交订单
export const submitOrder = (params) => {
  return request('/member/order', 'post', params)
}
// 订单详情
export const findOrderDetail = (orderId) => {
  return request(`/member/order/${orderId}`, 'get')
}
// 订单列表
export const findOrderList = ({ page = 1, pageSize = 10, orderState = 0 }) => {
  return request('/member/order/', 'get', { page, pageSize, orderState })
}
// 取消订单
export const cancelOrder = ({ orderId, cancelReason }) => {
  return request(`/member/order/${orderId}/cancel`, 'put', { cancelReason })
}
// 删除订单
export const deleteOrder = (orderId) => {
  return request('/member/order', 'delete', { ids: [orderId] })
}
// 确认收货
export const confirmOrder = (orderId) => {
  return request(`/member/order/${orderId}/receipt`, 'put')
}
// 查看物流
export const logisticsOrder = (id) => {
  return request(`/member/order/${id}/logistics`, 'get')
}
// 根据订单再次购买
export const repurchaseOrder = (orderId) => {
  return request(`/member/order/repurchase${orderId}`, 'get')
}
